package org.pitest.ant.util;

import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.types.FileSet;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Aidan Morgan
 */
public class FileSetUtils {
  public static List<File> convertFileSet(FileSet fs) {
    FileScanner scanner = fs.getDirectoryScanner(fs.getProject());
    scanner.scan();

    List<File> result = new ArrayList<File>();
    for (String f : scanner.getIncludedFiles()) {
      File res = new File(scanner.getBasedir(), f);

      result.add(res);
    }

    return Collections.unmodifiableList(result);
  }
}
